package com.xxx.controller;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.xxx.config.Request;
import com.xxx.pojo.ClientDetail;
import com.xxx.pojo.User;
import com.xxx.service.ClientDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author George
 * @since 2023-07-06
 */
@Api(tags = "客户详情控制")
@CrossOrigin
@RestController
@RequestMapping("/client-detail")
public class ClientDetailController {

    @Resource
    private ClientDetailService clientDetailService;

    /**
     * 修改客户信息
     *
     * @param newClientId 部门id
     * @return 返回操作结果
     */
    @ApiOperation(value = "修改客户信息", notes = "修改客户信息")
    @PutMapping("/updateClient")
    public Request updateClient(
                              @RequestParam("newClientId") Long newClientId,
                              @RequestParam("clientMemo") String clientMemo,
                              @RequestParam("labelId") Integer labelId) {

        ClientDetail byId = clientDetailService.getById(newClientId);
        if (byId == null) {
            return Request.error("未找到该客户");
        }
        byId.setClientDetailMemo(clientMemo);
        byId.setLabelId(labelId);

        boolean updated = clientDetailService.updateById(byId);
        return updated ? Request.suc() : Request.error("修改客户信息失败");
    }

}

